package com.sudichina.sudichina.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.sudichina.sudichina.bean.AddCityWeightBean;

import java.util.ArrayList;
import java.util.List;


public abstract class MySuperListViewAdapter extends BaseAdapter {


    private final List<?> list;
    private AddCityWeightBean addCityWeightBean;
    private ArrayList<String> mDatas;

    public MySuperListViewAdapter(List<?> list) {
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        BaseListViewViewHolder holder;
//        if (convertView == null) {
//
//            holder = setHolder();
//           // convertView = View.inflate(parent.getContext(), holder.getItemId(), null);
//
//            // TODO:   这里为了避免未知的错误,直接使用的是三个参数的方法
//            convertView = LayoutInflater.from(parent.getContext()).inflate(holder.getItemId(), parent, false);
//
//            convertView.setTag(holder);
//
//        } else {
//
//            holder = (BaseListViewViewHolder) convertView.getTag();
//        }
        holder = setHolder();
        View view = LayoutInflater.from(parent.getContext()).inflate(holder.getItemId(), parent, false);

        holder.setDatas(view, list.get(position), position);

        return view;
    }

    public abstract BaseListViewViewHolder setHolder();


}

